package com.ruoyi.boat.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * 状态对象 t_status
 *
 * @author ruoyi
 * @date 2023-07-31
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class Status extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    private Long id;

    /**
     * 流水号
     */
    @Excel(name = "流水号")
    private Integer serialNum;

    /**
     * 波浪艇编号
     */
    @Excel(name = "艇编号")
    private String boatCode;

    /**
     * 经度
     */
    @Excel(name = "经度")
    private Double lng;

    /**
     * 纬度
     */
    @Excel(name = "纬度")
    private Double lat;

    /**
     * 目标地序列号
     */
    @Excel(name = "目标地序列号")
    private Integer destNum;

    /**
     * 航速
     */
    @Excel(name = "航速")
    private Double speed;

    /**
     * 航向 暂无
     */
    @Excel(name = "航向")
    private Double course;

    /**
     * 舵角
     */
    @Excel(name = "舵角")
    private Integer rudderAngle;

    /**
     * 水面艏向
     */
    @Excel(name = "水面艏向")
    private Double headingUp;

    /**
     * 水下艏向
     */
    @Excel(name = "水下艏向")
    private Double headingDown;

    /**
     * 水面俯仰角
     */
    @Excel(name = "水面俯仰角")
    private Integer pitchUp;

    /**
     * 水下俯仰角
     */
    @Excel(name = "水下俯仰角")
    private Integer pitchDown;

    /**
     * 水面横滚角
     */
    @Excel(name = "水面横滚角")
    private Integer rollUp;

    /**
     * 水下横滚角 暂无
     */
    @Excel(name = "水下横滚角")
    private Integer rollDown;

    /**
     * 电压1
     */
    @Excel(name = "电压1")
    private Double voltage1;

    /**
     * 电压2
     */
    @Excel(name = "电压2")
    private Double voltage2;

    /**
     * 电压3
     */
    @Excel(name = "电压3")
    private Double voltage3;

    /**
     * 电量
     */
    @Excel(name = "电量")
    private Double capacitor;

    /**
     * 控制模式
     */
    @Excel(name = "控制模式", readConverterExp = "0=手动,1=自动")
    private Integer controlMode;

    /**
     * 8路开关量
     */
    @Excel(name = "8路开关量")
    private Integer alert;

    /**
     * 水面旋转圈数
     */
    @Excel(name = "水面旋转圈数")
    private Integer rotationUp;

    /**
     * 水下旋转圈数
     */
    @Excel(name = "水下旋转圈数")
    private Integer rotationDown;

    /**
     * 水下受力
     */
    @Excel(name = "水下受力")
    private Integer pressure;

    /**
     * 系统状态
     */
    @Excel(name = "系统状态")
    private Integer systemStatus;

    /**
     * 执行机构状态
     */
    @Excel(name = "执行机构状态")
    private Integer actuatorStatus;

    /**
     * 载荷开关状态
     */
    @Excel(name = "载荷开关状态")
    private Integer loadStatus;

    /**
     * 偏差
     */
    @Excel(name = "偏差")
    private Double deviation;

    /**
     * 数据时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "数据时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date time;
    //查询时候用
    private Date beginTime;
    private Date endTime;

    public boolean getChecked(int index,int expect){
        return (loadStatus >> index & 0x01) == expect;
    }
}
